﻿@model TeamSearchResultViewModel

@{ 
    var routeValues = new { area = "TeamArea", id = Model.TeamVersion.Pk };
    string controller = ViewContext.RouteData.GetRequiredString("controller");
    string action = ViewContext.RouteData.GetRequiredString("action");
}

<div class="grid_12 header-section clearfix">

    @if (Model.TeamVersion.Pk != null)
    {
        <div>
            <a class="search2" href="@Url.Action("Index", "Details", new { area = "CountryArea", id = Model.TeamVersion.CountryGuid })">
                @Model.TeamVersion.Country.CountryName
            </a>

            @if (!Model.TeamVersion.IsApproved)
            {
                <span class="k-icon k-i-note" title="Awaiting approval."></span>
            }
        </div>
    }

    <h2>@Model.TeamVersion.TeamName</h2>

    <div class="search2">@string.Format("{0} - {1}", Model.TeamVersion.ActiveFrom._ToDisplayString(), Model.TeamVersion.ActiveTo._ToDisplayString())</div>
</div>

@if (!Model.TeamVersion.IsMarkedForDeletion)
{
    <div class="grid_12 submenu clearfix">
        @(Html.Kendo().Menu()
            .Name("TeamMenu")
            .HighlightPath(false)
            .Items(items =>
            {
                items.Add()
                    .Text("Summary")
                    .Action("Index", "Details", new { id = Model.TeamVersion.Pk })
                    .Selected(action == "Index" && controller == "Details");

                items.Add()
                    .Text("Editor")
                    .Items(editorItems =>
                    {
                        editorItems.Add()
                            .Text("Edit")
                            .Action("Index", "Editor", new { id = Model.TeamVersion.Pk })
                            .Visible(Model.IsEditVisible)
                            .Selected(action == "Index" && controller == "Editor");

                        editorItems.Add()
                            .Text("Delete")
                            .HtmlAttributes(new { onclick = "return confirm('Are you sure?');" })
                            .Action("Delete", "Editor", new { id = Model.TeamVersion.Pk })
                            .Visible(Model.IsDeleteVisible)
                            .Selected(action == "Delete" && controller == "Editor");

                        editorItems.Add()
                            .Text("Create new version")
                            .Action("CreateVersion", "Editor", new { id = Model.TeamVersion.Pk })
                            .Visible(Model.CanCreateVersion)
                            .Selected(action == "CreateVersion" && controller == "Editor");

                        editorItems.Add()
                            .Text("View approvals")
                            .Action("RecordForApproval", "Editor", new { id = Model.TeamVersion.Pk })
                            .Visible(Model.IsViewApprovalsVisible)
                            .Selected(action == "RecordForApproval" && controller == "Editor");
                    });
            })
        )
    </div>
}
